package icu.groot.alan;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import icu.groot.alan.entity.ReportExport;
import icu.groot.alan.util.MergeStrategy;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        exportExcel();

    }
    private static void exportExcel(){
        List<String> departments = new ArrayList<>();
        departments.add("管理员");
        departments.add("花式部");
        departments.add("吕部");
        EasyExcel.write("test.xlsx", ReportExport.class)
                //不需要表头
                .needHead(false)
                .registerWriteHandler(new MergeStrategy(departments))
                .sheet("通用合并行策略")
                .doWrite(getFruitData());
    }
    // 模拟从数据库读取需要下载的列表信息
    private static List<ReportExport> getFruitData() {
        List<ReportExport> reports = new ArrayList<>();
        reports.add(new ReportExport("管理员"));
        reports.add(new ReportExport("工号", "姓名", "异常情况"));
        reports.add(new ReportExport("1001", "1001", "1001"));
        reports.add(new ReportExport("1002", "1002", "1001"));
        reports.add(new ReportExport("花式部"));
        reports.add(new ReportExport("工号", "姓名", "异常情况"));
        reports.add(new ReportExport("1003", "1003", "1001"));
        reports.add(new ReportExport("1004", "1004", "1001"));
        reports.add(new ReportExport("吕部"));
        reports.add(new ReportExport("工号", "姓名", "异常情况"));
        reports.add(new ReportExport("1005", "1005", null));
        return reports;
    }


}